<?php
$data=array(
	'uname'=>'jason',
	'gender'=>'male'
	);
$result=add('users',$data);
if($result)
{header('location:listusers.php');}
else
{header('location:test.php');}
function add($tbl,$data){
	// $kkeys=array_keys($data);
    $keys=implode(',', array_keys($data));
    $values=implode("','", array_values($data));
    echo "insert into users(uname,gender) values('jz','1')<br>";
	$sql="insert into ".$tbl." (".$keys.") values('$values')";
    $result=mysql_query($sql);
    if($result){
    	return mysql_insert_id();
    }
    else
    {
    	return 0;
    }
	echo $sql;

?>